
-- ----------------------------
-- Table structure for HIS_CONFIG_INFO
-- ----------------------------
CREATE TABLE "SYSTEM"."HIS_CONFIG_INFO" (
  "ID" NUMBER(20,0) NOT NULL,
  "NID" NUMBER(20,0) NOT NULL,
  "DATA_ID" NVARCHAR2(255) NOT NULL,
  "GROUP_ID" NVARCHAR2(128) NOT NULL,
  "APP_NAME" NVARCHAR2(128),
  "CONTENT" NCLOB NOT NULL,
  "MD5" NVARCHAR2(32),
  "GMT_CREATE" DATE NOT NULL,
  "GMT_MODIFIED" DATE NOT NULL,
  "SRC_USER" NCLOB,
  "SRC_IP" NVARCHAR2(50),
  "OP_TYPE" NCHAR(10),
  "TENANT_ID" NVARCHAR2(128),
  "ENCRYPTED_DATA_KEY" NCLOB
)
LOGGING
NOCOMPRESS
PCTFREE 10
INITRANS 1
STORAGE (
  INITIAL 65536 
  NEXT 1048576 
  MINEXTENTS 1
  MAXEXTENTS 2147483645
  FREELISTS 1
  FREELIST GROUPS 1
  BUFFER_POOL DEFAULT
)
PARALLEL 1
NOCACHE
DISABLE ROW MOVEMENT
;
COMMENT ON COLUMN "SYSTEM"."HIS_CONFIG_INFO"."APP_NAME" IS 'app_name';
COMMENT ON COLUMN "SYSTEM"."HIS_CONFIG_INFO"."TENANT_ID" IS '租户字段';
COMMENT ON COLUMN "SYSTEM"."HIS_CONFIG_INFO"."ENCRYPTED_DATA_KEY" IS '秘钥';
COMMENT ON TABLE "SYSTEM"."HIS_CONFIG_INFO" IS '多租户改造';

-- ----------------------------
-- Records of HIS_CONFIG_INFO
-- ----------------------------
COMMIT;
COMMIT;

-- ----------------------------
-- Primary Key structure for table HIS_CONFIG_INFO
-- ----------------------------
ALTER TABLE "SYSTEM"."HIS_CONFIG_INFO" ADD CONSTRAINT "SYS_C0012439" PRIMARY KEY ("NID");

-- ----------------------------
-- Checks structure for table HIS_CONFIG_INFO
-- ----------------------------
ALTER TABLE "SYSTEM"."HIS_CONFIG_INFO" ADD CONSTRAINT "SYS_C0012408" CHECK ("ID" IS NOT NULL) NOT DEFERRABLE INITIALLY IMMEDIATE NORELY VALIDATE;
ALTER TABLE "SYSTEM"."HIS_CONFIG_INFO" ADD CONSTRAINT "SYS_C0012409" CHECK ("NID" IS NOT NULL) NOT DEFERRABLE INITIALLY IMMEDIATE NORELY VALIDATE;
ALTER TABLE "SYSTEM"."HIS_CONFIG_INFO" ADD CONSTRAINT "SYS_C0012410" CHECK ("DATA_ID" IS NOT NULL) NOT DEFERRABLE INITIALLY IMMEDIATE NORELY VALIDATE;
ALTER TABLE "SYSTEM"."HIS_CONFIG_INFO" ADD CONSTRAINT "SYS_C0012411" CHECK ("GROUP_ID" IS NOT NULL) NOT DEFERRABLE INITIALLY IMMEDIATE NORELY VALIDATE;
ALTER TABLE "SYSTEM"."HIS_CONFIG_INFO" ADD CONSTRAINT "SYS_C0012412" CHECK ("CONTENT" IS NOT NULL) NOT DEFERRABLE INITIALLY IMMEDIATE NORELY VALIDATE;
ALTER TABLE "SYSTEM"."HIS_CONFIG_INFO" ADD CONSTRAINT "SYS_C0012413" CHECK ("GMT_CREATE" IS NOT NULL) NOT DEFERRABLE INITIALLY IMMEDIATE NORELY VALIDATE;
ALTER TABLE "SYSTEM"."HIS_CONFIG_INFO" ADD CONSTRAINT "SYS_C0012414" CHECK ("GMT_MODIFIED" IS NOT NULL) NOT DEFERRABLE INITIALLY IMMEDIATE NORELY VALIDATE;

-- ----------------------------
-- Indexes structure for table HIS_CONFIG_INFO
-- ----------------------------
CREATE INDEX "SYSTEM"."IDX_DID"
  ON "SYSTEM"."HIS_CONFIG_INFO" ("DATA_ID" ASC)
  LOGGING
  VISIBLE
PCTFREE 10
INITRANS 2
STORAGE (
  INITIAL 65536 
  NEXT 1048576 
  MINEXTENTS 1
  MAXEXTENTS 2147483645
  FREELISTS 1
  FREELIST GROUPS 1
  BUFFER_POOL DEFAULT
);
CREATE INDEX "SYSTEM"."IDX_GMT_CREATE"
  ON "SYSTEM"."HIS_CONFIG_INFO" ("GMT_CREATE" ASC)
  LOGGING
  VISIBLE
PCTFREE 10
INITRANS 2
STORAGE (
  INITIAL 65536 
  NEXT 1048576 
  MINEXTENTS 1
  MAXEXTENTS 2147483645
  FREELISTS 1
  FREELIST GROUPS 1
  BUFFER_POOL DEFAULT
);
CREATE INDEX "SYSTEM"."IDX_GMT_MODIFIED"
  ON "SYSTEM"."HIS_CONFIG_INFO" ("GMT_MODIFIED" ASC)
  LOGGING
  VISIBLE
PCTFREE 10
INITRANS 2
STORAGE (
  INITIAL 65536 
  NEXT 1048576 
  MINEXTENTS 1
  MAXEXTENTS 2147483645
  FREELISTS 1
  FREELIST GROUPS 1
  BUFFER_POOL DEFAULT
);

-- ----------------------------
-- Triggers structure for table HIS_CONFIG_INFO
-- ----------------------------
CREATE TRIGGER "SYSTEM"."TG_DATE" BEFORE INSERT OR UPDATE ON "SYSTEM"."HIS_CONFIG_INFO" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW 
BEGIN
     IF INSERTING THEN     
        :NEW.GMT_CREATE := SYSDATE;
        :NEW.GMT_MODIFIED := SYSDATE;
    ELSIF UPDATING then     
        :NEW.GMT_MODIFIED := SYSDATE;
    END IF;    
END;
/
CREATE TRIGGER "SYSTEM"."TG_HIS_CONFIG" BEFORE INSERT ON "SYSTEM"."HIS_CONFIG_INFO" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW 
begin
select /*序列*/SEQ_ID.nextval into:new.nid/*主键*/ from dual;
-- select /*序列*/seq_test.nextval into:new.id/*主键*/ from dual;
end;
/
